package studysystem.demo.mapper;

import org.apache.ibatis.annotations.*;
import studysystem.demo.bean.Depend;


import java.util.List;

@Mapper
public interface DependMapper {

    //查询小类所属大类ID
    @Select("select class from course where name = #{name,jdbcType=VARCHAR}")
    int findClassByname(@Param("name") String name);

    //查询大类名字ByID
    @Select("select name from course_class where id = #{id,jdbcType=VARCHAR}")
    String findCourse_dirById(@Param("id")int id);

    //查询小类名字ByID
    @Select("select name from course where id = #{id,jdbcType=VARCHAR}")
    String findCourseById(@Param("id")int id);

    //查询小类名字ByID
    @Select("select id from course where name = #{name,jdbcType=VARCHAR}")
    int findCourseIdByName(@Param("name")String name);

    //查询所有小类
    @Select("select name from course ")
    List<Depend> findAllDepend();

    //查询所有小类条数
    @Select("select count(*) from course")
    int findAllDependCount();

    //查询是否存在小类
    @Select("select name from course where name like CONCAT(CONCAT('%', #{name}), '%')")
    List<Depend> findDependByname(String  name);

    //查询是否存在小类2
    @Select("select name from course where name = #{name,jdbcType=VARCHAR}")
    String findDependByname2(String  name);

    //查询小类条数 (小类名 模糊查询)
    @Select("select count(*) from course where name like CONCAT(CONCAT('%', #{name}), '%')")
    int findAlldDependCountByName(String name);

    //查询小类(小类名  模糊查询)
    @Select("select name from course where name like CONCAT(CONCAT('%', #{name}), '%')")
    List<Depend> findAllDependByName(String name);

    //查询小类依赖(小类名  模糊查询)
    @Select("select name,lastcourse,nextcourse from course where name = #{name,jdbcType=VARCHAR}")
    List<Depend> findCourseDependByName(String name);

    //修改文档资源
    @Update("update course set lastcourse = #{lastcourse,jdbcType=VARCHAR},nextcourse = #{nextcourse,jdbcType=VARCHAR} where name = #{name,jdbcType=VARCHAR}")
    void updateDepend(Depend courserEntity);

}
